home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
wdj0797.zip
/
TUFFS.ZIP
/
EXCEPT8.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1997-04-22
|
864b
|
37 lines
// File: except8.cpp
#include <iostream.h>
#include <except.h>
#include <cstring.h>
#include "warning.h"
void badFunction()
{
char *p = (char*)GlobalLock(GlobalAlloc(GHND, 10));
cout << "Setting p to zero..." << endl;
memset(p, 0, -10);
}
int main()
{
IssueWarning();
for (int i=0; i<2; i++)
{
DWORD code = 0;
try
{
try
{
cout << "Calling badFunction()" << endl;
badFunction();
cout << "badFunction() completed without exception" << endl;
} catch (xmsg &x) {
cerr << "Exception caught '" << x.why() << "'" << endl;
} catch (...) {
cerr << "Unknown exception caught" << endl;
}
} __except (code=GetExceptionCode(), 1) {
cerr << "Unknown system exception " << hex << code << " caught" << endl;
}
}
return 0;
}